
import 'dart:convert';

import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:get/get_core/src/get_main.dart';
import 'package:qianyi/entity/home/alumb_vo_list.dart';
import 'package:qianyi/entity/home/trendVo.dart';
import 'package:qianyi/entity/mine/Collection.dart';
import 'package:qianyi/network/http_entity.dart';
import 'package:shared_preferences/shared_preferences.dart';

import '../../controller/imageDetailUserController.dart';
import '../../entity/profile/my_user_info_entity.dart';
import '../../network/base_entity.dart';
import '../../network/http_config.dart';
import '../../network/http_manager.dart';
import '../../ui/widget/custom_refresh_mixin.dart';
import '../../utils/navigator_util.dart';


class ImageCollectionViewModel extends ChangeNotifier with CustomRefreshMixin {
  int? type2 = 0;
  TabController? tabController;
  ImageCollectionViewModel(int type2) {
    this.type2 = type2;
  }
  ImageDetailUserController imageDetailUserController = Get.find();



  @override
  Future<List> requestList(int page) async {
    List tempL = [];
    SharedPreferences prefs = await SharedPreferences.getInstance();
    Map<String,dynamic> userInfo = jsonDecode(prefs.getString("userInfo")!);


    Map<String, dynamic> params = {};
    params["uid"] = imageDetailUserController.userId;
    params["type"] = type2;
    IBaseEntity? result = await HttpManager.getInstance().request(url: "/platform/agreeCollect/getAllCollection/${page}/10",method: Method.get, params: params);
    HttpEntity httpEntity = result as HttpEntity;
    CollectionList trendEntityList;
    if(type2 == 3) {
      trendEntityList = CollectionList.fromJson(httpEntity.oriData['data']['records']);

    } else {
      trendEntityList = CollectionList.fromJson(httpEntity.oriData['data']['records']);

    }

    if(trendEntityList.collections != null) {
      tempL.addAll(trendEntityList.collections);

    }
    notifyListeners();
    return tempL;
  }

}
